package cn.tedu.security.config;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler
    public String handleException(InternalAuthenticationServiceException e) {
        return "username error";
    }

    @ExceptionHandler
    public String handleException(BadCredentialsException e) {
        return "password error";
    }

    @ExceptionHandler
    public String handleException(DisabledException e) {
        return "account disabled";
    }

    @ExceptionHandler
    public String handleException(AccessDeniedException e) {
        return "无此权限";
    }

}
